﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TaxLawView
{
    public class LazyTreeView : TreeView
    {
        public event EventHandler<ItemExpandedEventArgs> ItemExpanded;
        protected override DependencyObject GetContainerForItemOverride()
        {
            TreeViewItem item = new LazyTreeViewItem();
            item.Expanded += new RoutedEventHandler(item_Expanded);
            return item;
        }

        void item_Expanded(object sender, RoutedEventArgs e)
        {
            OnItemExpanded((LazyTreeViewItem)sender);
        }

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
        }

        internal void OnItemExpanded(LazyTreeViewItem item)
        {
            if (ItemExpanded != null)
            {
                ItemExpanded(this, new ItemExpandedEventArgs(item));
            }
        }
    }
}
